package cz.cuni.amis.episodic.data;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.ToString;

/**
 * Episodic hierarchy represented as [hierarchy level, time] 2d array.
 * Observations have level 0, 1st level episodes have level 1 etc.
 * This structure includes exactly one trajectory of episodes. It does not store any probabilities.
 * @author ik
 *
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class EpisodicHierarchyInstance {
	
	List<List<String>> hierarchyByTime = new ArrayList<>();

	public EpisodicHierarchyInstance(int depth) {
		for(int i = 0; i < depth; i++)
			hierarchyByTime.add(new ArrayList<String>());
	}

	public String toString() {
		StringBuilder b = new StringBuilder();
		for(int i = hierarchyByTime.size() - 1; i >= 0; i--) {
			b.append("Level " + i + " ");
			b.append(StringUtils.join(hierarchyByTime.get(i), '\t'));
			b.append("\n");
		}
		return b.toString();
	}
}
